Skip to content

[popups] Skip the focus-out close for a popup that already closed - #6088

Merged
atomiks merged 1 commit into
mui:masterfrom
mkantautas:fix/focus-out-after-close
Nov 10, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
mkantautas:fix/focus-out-after-close

Conversation

@mkantautas

Copy link
Copy Markdown
Contributor

Fixes #6041.

FloatingFocusManager keeps its focus-out listeners while a closed popup is still mounted, during the exit animation or after preventUnmountOnClose(). When focus then left the trigger, its queued close called onOpenChange(false) with reason focus-out again for a popup that had already closed. A non-modal Popover or Dialog closed by tabbing away from its trigger reported the close more than once, also without an exit animation, and a popup kept mounted with preventUnmountOnClose() reported another close each time focus left the trigger. Menu was not affected because its store ignores a close when it is already closed.

The focus-out close now runs only while the popup is open. preventReturnFocusRef is still set as before, so with an explicit finalFocus, focus that the user moved during the exit animation stays where it is.

The new test fails on master: focus leaving the reference of a closed, still-mounted floating element reports [false, 'focus-out']. Its sibling case checks that an open one still closes.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

commit: f7622a5

@code-infra-dashboard

code-infra-dashboard Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+18B(0.00%) 🔺+5B(0.00%)

Details of bundle changes

Performance

No regressions in 36 benchmarks · ran 3m 49s · details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f7622a5
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6af2a3a1ee1c0afcbe1c21f8
😎 Deploy Preview https://deploy-preview-6088--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@zannager zannager added the component: popover Changes related to the popover component. label Oct 27, 2026

@atomiks atomiks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@atomiks atomiks added type: bug It doesn't behave as expected. component: dialog Changes related to the dialog component. labels Nov 10, 2026
@atomiks
atomiks force-pushed the fix/focus-out-after-close branch from e23a890 to f7622a5 Compare November 10, 2026 04:54
@atomiks
atomiks enabled auto-merge (squash) November 10, 2026 04:56
@atomiks
atomiks merged commit ea289b9 into mui:master Nov 10, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: dialog Changes related to the dialog component. component: popover Changes related to the popover component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[popover][select][dialog] onOpenChange(false) fires again with reason "focus-out" for a popup that is already closed

3 participants